#include "binswap.cpp"

int other_ok(CBinCode* X, CPermutation& a) {
	for (int i=0; i<X[2].k &&
			!( X[2].row[i].is_set(a.tr[0]) ^ X[2].row[i].is_set(a.tr[1]) ) ;
			i++ ) ;
	return (i==X[2].k) ? 1 : 0 ;

}

main (int argc, char *argv[]) {

		CBinCode *X ;
		CPermutation a(28) ;
		CBinWord tmp1(4), tmp2(7), r1(28), r2(28) ;
		char* fname = (argv[1][0]) ? argv[1] : "tst9" ;
    filter (fname, X, 	NULL ) ;
		int mycnt = 0 ;
		X[0].convert() ;
		CBinCode C(14, 28) ;
		C = X[0] ;

		for ( int i1=0; i1<28; i1++ )	{
			for ( int j1=i1+1; j1<28; j1++ )	{
				a.tr[0] = i1 ;
				a.tr[1] = j1 ;
				if ( other_ok(X, a) ) {
					a.col_swap(C) ;
					cerr << "transp :  " << i1 << " " << j1 << endl ;
					mycnt = 0 ;
					for ( int i=1; i < (1 << tmp1.n); i++ )	{
						for ( int j=1; j < (1 << tmp2.n); j++ )	{

							tmp1.num = i ;
							tmp2.num = j ;
							r1 = tmp1^tmp2 ;
							r2 = tmp2^tmp1 ;

							if ( ! (C*r1).num ) {
								mycnt++ ;
								cout << r1 << endl;
								cerr << " = " << tmp1 << " ^ " << tmp2 << endl;
							}

							if ( ! (C*r2).num ) {
								mycnt++ ;
								cout << r2 << endl;
								cerr << " = " << tmp2 << " ^ " << tmp1 << endl;
							}
						}
					}
					cout << '*' << endl ;
					cerr << "count :  " << mycnt << endl ;
					if ( mycnt >= 14 ) {
						C.convert() ;
						cout << "it is C :\n" << C ;
						cerr << "yes:....." << mycnt << endl;
						exit(0) ;
					}
				}
				C = X[0] ;
			}
		}
		/*
		 cout << X[1] ;
		int bl=0 ;
		for ( int j=0; j<X[1].k; j++)	{
			for ( int i=0; i<28; i++ ) {
				if ( I & (X[1].row[j].num >> i) )	{
					a.tr[bl] = i ;
					bl = (bl) ? 0 : 1 ;
					if ( !bl && other_ok(X, a)) {
						a.col_swap(X[0]);
						cerr << a.tr[0] <<" "<<a.tr[1] << endl ;
						cout << X[0] ;
						cerr << "yes ...\n" ;
						exit(0) ;
					}
				}
			}
		}
		// cerr << X[0] ;
		*/
return 0;
}
